<template>
  <div class="person">
    <h2>我是Person组件</h2>
    <h4>姓名：{{name}}</h4>
    <h4>年龄：{{age}}</h4>
    <h4>性别：{{gender}}</h4>
    <h4>座驾：{{car}}</h4>
    <button @click="changeAge">强哥的年龄+1</button>
    <button @click="changeName">改强哥的名字</button>
    <button @click="changeCarColor">修改车的颜色</button>
    <button @click="changeAllCar">修改整个车</button>
  </div>
</template>

<script>
  export default {
    name:'Person',
    // 接收父传递过来的name、age、gender数据，收到了自己的vc上，所以模板中可以直接使用
    props:['name','age','gender','car'],
    methods: {
      changeAge(){
        this.age += 1
      },
      changeName(){
        this.name = 'xiao-high'
      },
      changeCarColor(){
        this.car.color = '蓝色'
      },
      changeAllCar(){
        this.car = {brand:'奥拓',color:'紫色'}
      }
    },
  }
</script>

<style scoped>
  .person {
    background-color: skyblue;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
  }
</style>